package listeners;

import utilities.Workbench;
import android.graphics.Color;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class ColorSwitcher implements OnClickListener{
	
	private Workbench workbench;
	private Button clickedButton;
	
	public ColorSwitcher(Workbench wb, Button bu){
		
		this.workbench = wb;
		this.clickedButton = bu;
	}

	@Override
	public void onClick(View v) {

		
		if (clickedButton.getText().equals("blue")) {
			workbench.setTheChosenColor(Color.BLUE);
			workbench.getConsole().setText("bluebuttonpressed");
			workbench.getTheChosenColorButton().setBackgroundColor(Color.BLUE);
		}else if (clickedButton.getText().equals("red")) {
			workbench.setTheChosenColor(Color.RED);
			workbench.getTheChosenColorButton().setBackgroundColor(Color.RED);
			workbench.getConsole().setText("redbuttonpressed");
		}else if(clickedButton.getText().equals("green")){
			workbench.setTheChosenColor(Color.GREEN);
			workbench.getConsole().setText("greenbuttonpressed");
			workbench.getTheChosenColorButton().setBackgroundColor(Color.GREEN);
		}else if(clickedButton.getText().equals("yellow")){
			workbench.setTheChosenColor(Color.YELLOW);
			workbench.getConsole().setText("yellowbuttompressed");
			workbench.getTheChosenColorButton().setBackgroundColor(Color.YELLOW);
		}
	}

}
